
def create_Rect_StirrupRF
      model = Sketchup.active_model
      prompts = ["长度", "宽度", "保护层","箍筋直径"]
  		defaults = ["750", "700","25","10"]
  		input = UI.inputbox(prompts, defaults, "创建矩形箍")
      group = model.active_entities.add_group
		  entities = group.entities
			points = [
				Geom::Point3d.new(0,   0,   0),
				Geom::Point3d.new(input[0].to_f.mm, 0,   0),
				Geom::Point3d.new(input[0].to_f.mm, input[1].to_f.mm, 0),
				Geom::Point3d.new(0,   input[1].to_f.mm, 0)
			]

      entities.add_line points
      def getStrr1(b,h,layer,dia,model)#输入长宽、箍直径等参数，输出方箍平面8个角点

        group = model.active_entities.add_group
        entities = group.entities

        o1x = layer+dia/2+2.5*dia                 #o1-4是方箍的4个打弯圆心点
        o1y = layer+dia/2+2.5*dia
        o3x = b-layer-dia/2-2.5*dia               #o1-4是方箍的4个打弯圆心点
        o3y = h-layer-dia/2-2.5*dia

        points = [                                  #8个角点
          Geom::Point3d.new(o1x,  o1y-2.5*dia,   0),
          Geom::Point3d.new(o1x-2.5*dia,  o1y,   0),
          Geom::Point3d.new(o1x-2.5*dia,  o3y,   0),
          Geom::Point3d.new(o1x,  o3y+2.5*dia,   0),
          Geom::Point3d.new(o3x,  o3y+2.5*dia,   0),
          Geom::Point3d.new(o3x+2.5*dia,  o3y,   0),
          Geom::Point3d.new(o3x+2.5*dia,  o1y,   0),
          Geom::Point3d.new(o3x,  o1y-2.5*dia,   0),
          Geom::Point3d.new(o1x,  o1y-2.5*dia,   10.to_f.mm)
        ]
        sin45 = 0.707
        tth1X = o1x+2.5*dia*sin45
        tth1y = o1y-2.5*dia*sin45
        tth2X = tth1X+10*sin45*dia
        tth2y = tth1y+10*sin45*dia
        edges = entities.add_line Geom::Point3d.new(tth1X,tth1y,0),Geom::Point3d.new(tth2X,tth2y,0)

        vector = Geom::Vector3d.new 1,1,0
        vector2 = vector.normalize!
        face = entities.add_face(entities.add_circle Geom::Point3d.new(tth2X,tth2y,0), vector2, dia/2)

        tth3X = o1x-2.5*dia*sin45
        tth3y = o1y+2.5*dia*sin45
        tth4X = tth3X+10*sin45*dia
        tth4y = tth3y+10*sin45*dia
        entities.add_line Geom::Point3d.new(tth3X,tth3y,10.to_f.mm),Geom::Point3d.new(tth4X,tth4y,10.to_f.mm)
        entities.add_line points[1],points[2]
        entities.add_line points[3],points[4]
        entities.add_line points[5],points[6]
        entities.add_line points[7],points[8]

        vector = Geom::Vector3d.new 0,0,1
        vector2 = Geom::Vector3d.new 1,0,0
        vector3 = vector.normalize!
        cpoint1 =   Geom::Point3d.new(o1x,  o1y,   0)
        cpoint2 =   Geom::Point3d.new(o1x,  o3y,   0)
        cpoint3 =   Geom::Point3d.new(o3x,  o3y,   0)
        cpoint4 =   Geom::Point3d.new(o3x,  o1y,   0)
        cpoint5 =   Geom::Point3d.new(o1x,  o1y,   10.to_f.mm)
        entities.add_arc cpoint1, vector2, vector3, 2.5*dia, 180.degrees, 315.degrees
        entities.add_arc cpoint2, vector2, vector3, 2.5*dia, 180.degrees, 90.degrees
        entities.add_arc cpoint3, vector2, vector3, 2.5*dia, 0.degrees, 90.degrees
        entities.add_arc cpoint4, vector2, vector3, 2.5*dia, 270.degrees, 360.degrees
        entities.add_arc cpoint5, vector2, vector3, 2.5*dia, 135.degrees, 270.degrees
        #entities.add_line points[5,6]
        #entities.add_line points[7,0]


        face.followme(edges.all_connected)

      end
      def getStrr2(b,h,layer,dia,model)#输入长宽、箍直径等参数，输出方箍平面8个角点

        group = model.active_entities.add_group
        entities = group.entities

        o1x = layer+dia/2+2.5*dia                 #o1-4是方箍的4个打弯圆心点
        o1y = layer+dia/2+2.5*dia
        o3x = b-layer-dia/2-2.5*dia               #o1-4是方箍的4个打弯圆心点
        o3y = h-layer-dia/2-2.5*dia

        points = [                                  #8个角点
          Geom::Point3d.new(o1x,  o1y-2.5*dia,   0),
          Geom::Point3d.new(o1x-2.5*dia,  o1y,   0),
          Geom::Point3d.new(o1x-2.5*dia,  o3y,   0),
          Geom::Point3d.new(o1x,  o3y+2.5*dia,   0),
          Geom::Point3d.new(o3x,  o3y+2.5*dia,   0),
          Geom::Point3d.new(o3x+2.5*dia,  o3y,   0),
          Geom::Point3d.new(o3x+2.5*dia,  o1y,   0),
          Geom::Point3d.new(o3x,  o1y-2.5*dia,   0),
          Geom::Point3d.new(o1x,  o3y+2.5*dia,   10.to_f.mm)
        ]
        sin45 = 0.707
        tth1X = o1x+2.5*dia*sin45
        tth1y = o3y+2.5*dia*sin45
        tth2X = tth1X+10*sin45*dia
        tth2y = tth1y-10*sin45*dia
        edges = entities.add_line Geom::Point3d.new(tth1X,tth1y,0),Geom::Point3d.new(tth2X,tth2y,0)

        vector = Geom::Vector3d.new 1,-1,0
        vector2 = vector.normalize!
        face = entities.add_face(entities.add_circle Geom::Point3d.new(tth2X,tth2y,0), vector2, dia/2)

        tth3X = o1x-2.5*dia*sin45
        tth3y = o3y-2.5*dia*sin45
        tth4X = tth3X+10*sin45*dia
        tth4y = tth3y-10*sin45*dia
        entities.add_line Geom::Point3d.new(tth3X,tth3y,10.to_f.mm),Geom::Point3d.new(tth4X,tth4y,10.to_f.mm)
        entities.add_line points[1],points[2]
        entities.add_line points[8],points[4]
        entities.add_line points[5],points[6]
        entities.add_line points[7],points[0]

        vector = Geom::Vector3d.new 0,0,1
        vector2 = Geom::Vector3d.new 1,0,0
        vector3 = vector.normalize!
        cpoint1 =   Geom::Point3d.new(o1x,  o1y,   0)
        cpoint2 =   Geom::Point3d.new(o1x,  o3y,   0)
        cpoint3 =   Geom::Point3d.new(o3x,  o3y,   0)
        cpoint4 =   Geom::Point3d.new(o3x,  o1y,   0)
        cpoint5 =   Geom::Point3d.new(o1x,  o3y,   10.to_f.mm)
        entities.add_arc cpoint1, vector2, vector3, 2.5*dia, 180.degrees, 270.degrees
        entities.add_arc cpoint2, vector2, vector3, 2.5*dia, 180.degrees, 45.degrees
        entities.add_arc cpoint3, vector2, vector3, 2.5*dia, 0.degrees, 90.degrees
        entities.add_arc cpoint4, vector2, vector3, 2.5*dia, 270.degrees, 360.degrees
        entities.add_arc cpoint5, vector2, vector3, 2.5*dia, 225.degrees, 90.degrees
        #entities.add_line points[5,6]
        #entities.add_line points[7,0]


        face.followme(edges.all_connected)
        #ents = Sketchup.active_model.entities
        tr = Geom::Transformation.translation [0, 0, 100.to_f.mm]
        entities.transform_entities tr, group
      end

      getStrr1(input[0].to_f.mm,input[1].to_f.mm,input[2].to_f.mm,input[3].to_f.mm,model)
      getStrr2(input[0].to_f.mm,input[1].to_f.mm,input[2].to_f.mm,input[3].to_f.mm,model)
end
